package com.huilian.iotbox.admin.controller;

import com.huilian.iotbox.admin.service.DisplayRackService;
import com.huilian.iotbox.admin.service.UserService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.controller.BaseController;
import com.huilian.iotbox.data.dto.DisplayRackDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
 * @author LinYinDong
 * @date 2024/6/11 下午7:44
 */
@RestController
@RequestMapping("/api/displayRack")
public class DisplayRackController extends BaseController {

    @Resource
    private UserService userService;

    @Resource
    private DisplayRackService displayRackService;

    @PostMapping("/findDisplayRackList")
    public ServerResponse findDisplayRackList(HttpServletRequest request , @RequestBody DisplayRackDto displayRackDto)  {
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        UserInfo userInfo = userService.getLoginUserInfo(request);
        displayRackDto.setUserInfo(userInfo);
        displayRackDto.setPageNum(Integer.parseInt(pageNum));
        displayRackDto.setPageSize(Integer.parseInt(pageSize));
        return ServerResponse.createBySuccess(displayRackService.findDisplayByDeviceId(displayRackDto));
    }
}
